#include<bits/stdc++.h>
using namespace std;
const int N=2e5,lim=450;
int T,mod,n,now,dp[2][N+10],ans[N+10];
signed main(){
	freopen("moon.in","r",stdin);
	freopen("moon.out","w",stdout);
	ios::sync_with_stdio(0);
	cin.tie(0),cout.tie(0);
	cin>>T>>mod;
	dp[0][0]=1;
	for(int i=1;i<=lim;i++){
		for(int j=0;j<=N;j++)
			dp[now^1][j]=0;
		for(int j=1;j<=N;j++)
			if(j-(i-1)*2-1>=0) dp[now^1][j]=dp[now][j-(i-1)*2-1];
		now^=1;
		for(int j=1;j<=N;j++)
			if(j-i*2>=0) (dp[now][j]+=dp[now][j-i*2])%=mod,ans[j]+=dp[now][j],ans[j]%=mod;;
	}
	while(T--){
		cin>>n;
		cout<<ans[n]<<"\n";
	}
	return 0;
}